home *** CD-ROM | disk | FTP | other *** search
/ Fritz: All Fritz / All Fritz.zip / All Fritz / FILES / PROGBLER / A86V318A.LZH / A03.DOC < prev    next >
Text File  |  1988-06-24  |  14KB  |  320 lines

  1. CHAPTER 3   OPERATION AND REQUIREMENTS
  2.  
  3.  
  4. Creating Programs to Assemble
  5.  
  6. Before you invoke A86 you must have an assembly-language source
  7. program to assemble.  A source program is an ASCII text file,
  8. created with the text editor of your choice.  The editor must
  9. produce a file that is free of internal records known only to the
  10. editor.  Some of the fancier word processors will require you to
  11. use a "plain text" mode to insure that the file is free of such
  12. records.
  13.  
  14. This manual will fully explain to you the correct syntax of an
  15. A86 program, but it is not intended to teach you about the
  16. 86-family instruction set, or about assembly-language interfacing
  17. to your computer or your operating system.
  18.  
  19. The instruction set charts in Chapters 6 and 7 give concise,
  20. one-line descriptions of each instruction, but they don't go into
  21. any detail about instruction usage.  For such detail, I recommend
  22. either one of the two books The 8086/8088 Primer by Stephen P.
  23. Morse, or The 80286 Architecture by Morse and Albert.  The latter
  24. book covers the 8087/287 and is recommended if you have a
  25. floating-point coprocessor, or if you wish to explore the
  26. expanded capabilities of the 286.  (My 386 book is the latest in
  27. a series in which those two books are predecessors.)
  28.  
  29. To learn how to make system calls to input from keyboard or disk,
  30. output to screen, printer or disk, etc., you need a book that
  31. covers the MS-DOS operating system and the BIOS for the IBM-PC,
  32. or whatever computer you have if it's non-IBM-BIOS-compatible (if
  33. you don't know whether or not it's compatible, it probably is).
  34. I used Peter Norton's Programmer's Guide to the IBM-PC.  If
  35. you're less familiar with assembly language, you will probably
  36. want his Assembly Language Guide to the IBM-PC instead.
  37.  
  38.  
  39. Program Invocation
  40.  
  41. To invoke A86, you must provide a program invocation line, either
  42. typed to the console when the DOS command prompt appears, or
  43. included in a batch file.  The program invocation line consists
  44. of the following:
  45.  
  46. 1. The program name A86.
  47.  
  48. 2. The names of the source files you want to assemble.  You may
  49.    use the wild card delimiters * and ? if you wish, to denote a
  50.    group of source files to be assembled.  A86 will sort all
  51.    matching names into alphabetical order for each wild card
  52.    specification; so the files will be assembled in the same
  53.    order even if they get jumbled up within a directory.
  54.  
  55.    A86 identifies the end of the source file names when it sees a
  56.    name with no extension, or a name with the default object
  57.    extension (COM, BIN or OBJ, as described shortly).  Sorry, you
  58.    cannot have a source file with the default object extension.
  59.                                                               3-2
  60.  
  61. 3. You may optionally provide the word TO, to separate the source
  62.    file names from the output file names.
  63.  
  64. 4. The name of the output program.  If you do not provide an
  65.    extension, A86 will assume one of the following extensions:
  66.  
  67.    a. .OBJ if you invoked the +O switch, for linkable object file
  68.       production.
  69.  
  70.    b. .BIN if there is no +O switch, but there is an ORG 0 in
  71.       your program.
  72.  
  73.    c. .COM otherwise.
  74.  
  75.    If you want your program file to have no extension, you end
  76.    the file name with a period.
  77.  
  78.    You have the option to omit both the program file name and the
  79.    symbol table file name from the invocation.  If you do so, A86
  80.    will output the program source.COM (or source.OBJ or
  81.    source.BIN) and the symbol table source.SYM; where "source" is
  82.    a name derived from the list of source files, according to the
  83.    rules described in the section "Strategies for Source File
  84.    Maintenance" later in this chapter.
  85.  
  86. 5. The name of the symbol table file.  If you do not provide an
  87.    extension, A86 will assume that you want the extension .SYM.
  88.    If you want your symbol table file to have no extension, you
  89.    end the file name with a period.
  90.  
  91.    You have the option to omit the name of the symbol table file.
  92.    If you do so, A86 will use the same root as the output program
  93.    name, with a .SYM extension.  If you desire no symbol table
  94.    file, specify the +S switch in your invocation line or A86
  95.    environment variable (described later in this chapter).
  96.  
  97.  
  98. Assembler Switches
  99.  
  100. In addition to input and output file names, you may intersperse
  101. assembler switch settings anywhere after the A86 program name.
  102. They are all acted upon immediately, no matter where they are on
  103. the command line.  Some of the switches are discussed in more
  104. detail elsewhere; I'll summarize them here:
  105.  
  106. +C  causes the assembler to output symbol names with lower case
  107.     letters to its OBJ and SYM files.  The case of letters is
  108.     still ignored during assembly.  I output the name as it
  109.     appears in the last PUBLIC or EXTRN directive containing it;
  110.     if there is no such directive, I use the first occurrence of
  111.     the symbol to control which letters are output lower case.
  112.     (+C duplicates Microsoft MASM's /mx switch.)
  113.  
  114. +c  causes the assembler to consider the case of letters within
  115.     all non-built-in symbols as significant both during assembly
  116.     and for output.  Thus, for example, you can define different
  117.     symbols X and x.  (+c duplicates MASM's /ml switch.)
  118.                                                               3-3
  119.  
  120. +D  causes the default base for numeric constants to be decimal,
  121.     even if the constants have leading zeroes.
  122.  
  123. -D  causes the default base to be hexadecimal if there is a
  124.     leading zero; decimal otherwise.
  125.  
  126. +E  causes the error-message-augmented source file to be written
  127.     to yourname.ERR within the current directory, in all cases.
  128.     With +E, A86 will never rewrite your original source file.
  129.  
  130. -E  causes A86 to insert error messages into your source file,
  131.     whenever the file is in the current directory.  If the file
  132.     is not in the current directory, A86 write an ERR file no
  133.     matter what the E switch setting is.
  134.  
  135. +F  causes A86 to generate the 287 form of floating point
  136.     instructions (no implicit FWAIT bytes are generated before
  137.     the instructions).  This mode can also be specified in the
  138.     program with the .287 directive.
  139.  
  140. +f  causes A86 to support emulation of the 8087.  When A86 sees a
  141.     floating point instruction, it generates external references
  142.     to be resolved by the standard emulation library (provided by
  143.     Microsoft, Borland, etc.).  When you LINK your program to the
  144.     emulation library, the floating point instructions are
  145.     emulated by software.  NOTE you must be assembling to a
  146.     linkable OBJ file for this mode to have effect; otherwise, +f
  147.     is ignored.
  148.  
  149. -F  causes emulation and default-287 to be disabled.  You'll
  150.     still get 287 generation if there is a .287 directive in your
  151.     program.
  152.  
  153. +L  causes A86 to generate a longer (3-byte) instruction form for
  154.     an unconditional JMP instruction to a forward reference local
  155.     label, e.g. JMP >L1.  The code will usually be longer than
  156.     necessary, but you'll be spared having to occasionally go
  157.     back and code an explicit JMP LONG >L1.
  158.  
  159. -L  causes A86 to generate the more efficient 2-byte form for JMP
  160.     >L1.
  161.  
  162. +O  causes A86 to produce a linkable .OBJ file when the output
  163.     file name extension is not explicitly given.
  164.  
  165. -O  causes A86 to produce an executable .COM file when the output
  166.     file name extension is not explicitly given.
  167.  
  168. +S  suppresses the creation of the symbol table (.SYM) file in
  169.     normal (no errors) assembly.  This is overridden if you give
  170.     an explicit symbols file name in the invocation line.
  171.  
  172. -S  causes the symbol table file to be created in all cases.
  173.  
  174. +X  causes A86 to require that undefined names be explicitly
  175.     declared with an EXTRN when A86 is producing a linkable .OBJ
  176.     file.  The X switch has no effect when A86 is making a .COM
  177.     file.
  178.                                                               3-4
  179.  
  180. -X  causes A86 to quietly assume that all undefined names are
  181.     valid external references.
  182.  
  183. The default setting for all the switches is "minus".  Multiple
  184. switches can be specified with a single sign; e.g. +OX is the
  185. same as +O+X.
  186.  
  187.  
  188.  
  189. The A86 Environment Variable
  190.  
  191. To allow you to customize A86, the assembler examines the MS-DOS
  192. environment variable named "A86" when it is invoked.  If there is
  193. such a variable, its contents are inserted before the invocation
  194. command tail, as if you had typed them yourself.
  195.  
  196. For example, if you execute the command SET A86=+OX while in DOS
  197. (typically in the AUTOEXEC.BAT file run when the computer is
  198. started), then the O and X switches will be "plus", unless
  199. overridden with a "minus" setting in the command line.
  200.  
  201. You may also include one or more file names in the A86
  202. environment variable.  Those files will always be assembled
  203. first, before the files you specify on the command line.  This
  204. allows you to set up a library of macro definitions, which will
  205. always be automatically available to your programs.  Thus, for
  206. example, the DOS command  SET A86=C:\A86\MACDEF.8 +OX  will cause
  207. both the O and X switches to default ON, but will also cause the
  208. file MACDEF.8 of subdirectory A86 of drive C to always be
  209. assembled.
  210.  
  211.  
  212. Using Standard Input as a Command Tail
  213.  
  214. The following feature is a bit advanced.  If you're not familiar
  215. with the practice of redirecting standard input, you may safely
  216. skip this section.
  217.  
  218. A86 can also be configured to take its command arguments from
  219. standard input, in addition to the invocation command tail or the
  220. A86 environment variable.  This allows A86 to be used in those
  221. menu-driven systems that don't generate command tails for
  222. programs.  It also allows other programs to create lists of files
  223. to be assembled, then "pipe" the list to A86.
  224.  
  225. Here's how the feature works: when the command argument A86 is an
  226. ampersand &, A86 will prompt for standard input.  If the
  227. ampersand is seen but there are other things following it, the
  228. ampersand is ignored.
  229.  
  230. For example, you can place a list of file names and switch
  231. settings into a file called FILELIST.  You can then invoke the
  232. assembler via
  233.  
  234. A86 <FILELIST &
  235.  
  236. which will cause the contents of the FILELIST file to be used as
  237. a command line.
  238.                                                               3-5
  239.  
  240. You may place an ampersand at the end of your A86 environment
  241. variable.  If you do so, then A86 will prompt for file names
  242. whenever it is invoked without any command arguments (you type
  243. A86 followed immediately by the ENTER key to the MS-DOS prompt).
  244. This is the mode used if you have a menu system that can't
  245. generate an invocation command tail.
  246.  
  247. Note: when you redirect standard input so that it comes from a
  248. file, A86 will read all the lines of the file (up to a limit of
  249. 1023 bytes), and substitute spaces for the line breaks.  Thus you
  250. may give the file names on individual lines, for readability.
  251. However, if the feature is invoked manually (no redirection), so
  252. that you are typing in the line after the prompt, A86 will take
  253. the first line only.  You need to give all your switches and
  254. files on that one line.
  255.  
  256.  
  257.  
  258. Strategies for Source File Maintenance
  259.  
  260. A86 encourages modular programming, by letting you break your
  261. source into separate files, with complete impunity.  A86 has no
  262. concern whatsoever for file breaks-- it treats the sequence of
  263. files as a single source code stream.
  264.  
  265. You should consider one or more of the following strategies,
  266. which I have adopted in my source file management:
  267.  
  268. 1. I name all my A86 source files with the same extension, which
  269.    is found on no other files. The particular extension I have
  270.    chosen is ".8". I did not choose the more common .ASM, because
  271.    I have a few source files designed for MSDOS's assembler.  If
  272.    you don't like .8, I would suggest .A86.
  273.  
  274. 2. I keep a separate subdirectory on my hard disk for each
  275.    multi-source-file A86 program I have.  Then the simple command
  276.    "A86 *.8" performs the assembly for the current directory's
  277.    program.
  278.  
  279. 3. I exploit the fact that A86 expands wild cards into
  280.    alphabetical order.  Whenever I want a source file to be
  281.    assembled first (e.g., when it contains variable
  282.    declarations), I append a decimal digit to the start of the
  283.    file name: 0 for the first file, 1 for the second, etc., for
  284.    however many files that need to be explicitly ordered.  If a
  285.    file needs to come last, I append a "Z" to the start of the
  286.    file name.
  287.  
  288.    To accommodate this strategy, I have programmed A86 to a
  289.    somewhat complicated algorithm for determining the default
  290.    output file name.  I use the name of the first source file;
  291.    but I truncate the first character if it is a decimal digit.
  292.    However, you may have a general-purpose file that must come
  293.    first; so I have provided the following exception: if you have
  294.    a source file whose name begins with the digit "9", that name
  295.    (without the 9) is used.  If you don't like this, you can
  296.    always explicitly give the program name you want: "A86 *.8
  297.    MYPROG".
  298.                                                               3-6
  299.  
  300. System Requirements for A86
  301.  
  302. A86 requires MS-DOS V2.00 or later.  No BIOS or lower-level calls
  303. are made by A86, so A86 should run on any MS-DOS machine.  Please
  304. let me know if you find this not to be the case.
  305.  
  306. A86 itself is a small program, and it is fairly flexible about
  307. the memory it uses.  You can assemble small files with only 32K
  308. bytes of memory beyond the program itself, which in the current
  309. version is under 22K bytes-- a total of 54K bytes beyond the
  310. operating system. The more memory you have, the more capacity A86
  311. has, in symbol table size, source file size, and output file
  312. size.  If it can, A86 will use up to 256K bytes of memory.
  313.  
  314. As I just noted, in a small-memory system A86 severely limits the
  315. size of source files.  But remember that this doesn't hurt you
  316. badly: you can split up source files with impunity.  A86
  317. assembles a sequence of files as if it were a single source
  318. stream (similar to the INCLUDE facility of other assemblers).
  319.  
  320.